package com.atguigu.lease.web.admin.controller.apartment;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.web.admin.service.FileUploadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName: FileUploadController
 * Package: com.atguigu.lease.web.admin.controller.apartment
 * Description:
 *
 * @Author ygf
 * @Create 2024/9/14 10:24
 * @Version 1.0
 */
@Tag(name = "文件管理接口")
@RestController
@RequestMapping("/admin/file")
public class FileUploadController {

    @Autowired
    FileUploadService fileuploadService;

    @Operation(summary = "文件上传")
    @PostMapping("/upload")
    public Result<String> upload(@RequestParam MultipartFile file){//注意这里用MultipartFile这个类
        //调用service层
        String url = fileuploadService.upload(file);
        return Result.ok(url);
    }
}
